  var object={};
$(function(){
  var endId=[];
  var insertid;
  var deleteid;
  requestRefer();//已提交数据
  //跳转到详情界面
  $(".detail").click(function(){
	 var id= $(this).attr("data-id");
	window.location.href='realDetailTrial.jsp?detailId='+id;
	/* location.search = "?detailId="+id;*/
  })
  //删除按钮点击后
  $(".delete").click(function(){
	  deleteid="id="+$(this).attr("data-id");
	  alert(deleteid);
	  $("#delemodal").modal('show');
	 
  })
  //删除模态框确认
  $("#dele").click(function(){
	  requestDele(deleteid);
  })
  //跳转到修改页面
  $(".update").click(function(){
	  var id= $(this).attr("data-id");
		window.location.href='reUpdateTrial.jsp?update='+id;
  })
 
  //提交
  $(".insert").click(function(){
	  insertid="id="+$(this).attr("data-id");
	  $("#Mymodal").modal('show');
  })
  //提交模态框按钮
  $("#sure").click(function(){
	
	  requestSure(insertid);//调用提交方法;
  })
 //即时任务派遣
  $(".nowTask").click(function(){
	  var id= $(this).attr("data-id");
		window.location.href='dispatchTrial.jsp?detailId='+id;
  })
  //即时任务派遣分页显示
  $("#nowPage").click(function(){
	  window.location.href='realTimetask.jsp'//跳转到即时任务派遣分页
  })
  
})
//删除确认
function requestDele(id)
{
	alert(id);
	 var url=""//删除信息地址;
		  YuXi.util.get(url,id,function(data){
			  if(data.status)
			  {
				  $("#successmodel").modal('show');
			  }
			  else
			  {
				  $("#badmodal").modal('show');
			  }
		  },function(){
			  $("#badmodal").modal('show');
		  })
}
//提交按钮
function requestSure(id)
{
	  alert(id);
	  var url="";//提交的地址
	  YuXi.util.get(url,id,function(data){
		  if(data.status)
		  {
			  $("#successmodel").modal('show');
		  }
		  else
		  {
			 
			  $("#badmodal").modal('show');
		  }
	  },function(){
		  $("#badmodal").modal('show');
	  })
}

//向后台请求的信息数据
function requestRefer()
{	
	object=[
  	          {id:1,informationProfile:"待复核xssdsdsdadas",informationPerson:"xxx，xxx，xxxx",time:"2016-07-01"},
  	          {id:3,informationProfile:"待复核的撒到我的撒到我的撒到我的撒到我",informationPerson:"xxx，xxx，xxxx",time:"2016-07-01"},
  	          {id:5,informationProfile:"待复核xssdsdsdadas",informationPerson:"xxx，xxx，xxxx",time:"2016-07-01"},
  	          {id:6,informationProfile:"待复核xssdsdsdadas",informationPerson:"xxx，xxx，xxxx",time:"2016-07-01"},
  	          {id:9,informationProfile:"待复核的撒到我",informationPerson:"xxx，xxx，xxxx",time:"2016-07-01"},
  	          {id:10,informationProfile:"xssdsdsdadas",informationPerson:"xxx，xxx，xxxx",time:"2016-07-01"}
  	       ];
for(var i=0;i<object.length;i++)
{
	//模拟数据
	if( object[i].informationProfile.length>20)
		object[i].informationProfile= object[i].informationProfile.substring(0,15)+"...";
	var html="<tr ><td>"+(i+1)+"</td><td >"+object[i].informationProfile+"</td>"+
	"<td >"+object[i].informationPerson+"</td><td >"+object[i].time+"</td>"+
	"<td><a data-id="+object[i].id+" href='javascript:void(0)'; class='detail'>详情</a> &nbsp;&nbsp;<a data-id="+object[i].id+" href='javascript:void(0);' class='nowTask'>即时任务派遣</a></td></tr>";
	$("#table2body").append(html);
	$("#table3body").append(html);
	$("#table1body").append(html);
}


/*	var url="";
  YuXi.util.get(url,"null",function(data){
		object=data.object[0];
		for(var i=0;i<object.length;i++)
		{
			if( object[i].informationProfile.length>15)
				object[i].informationProfile= object[i].informationProfile.substring(0,15)+"...";
			var html="<tr ><td><input value="+object[i].id+" type='checkbox' data-id="+(i+1)+" name='together' >"+(i+1)+"</td><td >"+object[i].informationProfile+"</td>"+
			"<td>"+object[i].informationSource+"</td><td class='pets' >"+object[i].informationClassification+"</td>"+
			"<td >"+object[i].informationSort+"</td><td >"+object[i].informationPerson+"</td><td >"+object[i].time+"</td>"+
			"<td><a href='javascript:void(0);' class='detail'详情</a>&nbsp;&nbsp;<a data-id="+object[i].id+" href='javascript:void(0);' class='insert'>即时任务派遣</a>&nbsp;&nbsp;<a data-id="+object[i].id+" href='javascript:void(0);' class='update'>修改</a>&nbsp;&nbsp;<a data-id="+object[i].id+" href='javascript:void(0);' class='insert'>提交</a></td></tr>";
			
			$("#table1body").append(html);
		}
		
	
	},function(){});*/
}
//时间段查询
function  requestTime()
{
	var information={};
	//起始时间
	var start=$("#valStart").val();
	var end=$("#valEnd").val();
	var array=[];
	array=YuXi.timestamp.get(start,end,null);
	information.starttimestamp=array[0];
	information.endtimestamp=array[1];
	alert(JSON.stringify(information));
	
	//时间段查询
	/*var url="";
	 YuXi.util.get(url,information,function(data){
		 	object=data.object;
			for(var i=0;i<object.length;i++)
			{
				if( object[i].informationProfile.length>15)
					object[i].informationProfile= object[i].informationProfile.substring(0,15)+"...";
				var html="<tr ><td><input value="+object[i].id+" type='checkbox' name='together' data-id="+(i+1)+" >"+(i+1)+"</td><td>"+object[i].informationProfile+"</td>"+
				"<td>"+object[i].informationSource+"</td><td class='pets' >"+object[i].informationClassification+"</td>"+
				"<td >"+object[i].informationSort+"</td><td >"+object[i].informationPerson+"</td><td >"+object[i].time+"</td>"+
				"<td><a data-id="+object[i].id+" href='javascript:void(0);' class='detail'>详情</a> &nbsp;&nbsp;<a data-id="+object[i].id+" href='javascript:void(0);' class='update'>修改</a>&nbsp;&nbsp;<a data-id="+object[i].id+" href='javascript:void(0);' id='delete'>结束</a>&nbsp;&nbsp;<a data-id="+object[i].id+" href='javascript:void(0);' class='insert'>即时任务派遣</a>&nbsp;&nbsp;<a data-id="+object[i].id+" href='javascript:void(0);' class='insert'>提交</a></td></tr>";
				$("#tablebody").append(html);
			}
	 },function(){
		 //console.log("查询出错");
	 })*/
	
}
//简介，分级，渠道，状态，时间（今天,一周...）查找
function firstSearch()
{
	alert("------进入查询");
	var information={};
	information.informationProfile=$("#profile").val();//简介
/*	information.state=$(".state option:selected").val()//当前状态
*/	information.informationSource=$(".reSearchSource option:selected").val()//来源渠道
	information.pes=$(".reSearchpes option:selected").val()//分级

	var value=$(".valTime option:selected").val();
	var array=[];
	array=YuXi.timestamp.get(null,null,value);
	information.starttimestamp=array[0];
	information.endtimestamp=array[1];
	alert(JSON.stringify(information));
	
	//查询数据传送给后台
	 /* var url="";//地址
	  YuXi.util.get(url,information,function(data){
			object=data.object;
			for(var i=0;i<object.length;i++)
			{
				if( object[i].informationProfile.length>15)
					object[i].informationProfile= object[i].informationProfile.substring(0,15)+"...";
				var html="<tr ><td><input value="+object[i].id+" type='checkbox' name='together'data-id="+(i+1)+"  >"+(i+1)+"</td><td>"+object[i].informationProfile+"</td>"+
				"<td>"+object[i].informationSource+"</td><td class='pets' >"+object[i].informationClassification+"</td>"+
				"<td >"+object[i].informationSort+"</td><td >"+object[i].informationPerson+"</td><td >"+object[i].time+"</td>"+
				"<td><a data-id="+object[i].id+" href='javascript:void(0);' class='detail'>详情</a>&nbsp;&nbsp;<a data-id="+object[i].id+" href='javascript:void(0);' class='insert'>即时任务派遣</a>&nbsp;&nbsp;<a data-id="+object[i].id+" href='javascript:void(0);' class='insert'>提交</a></td></tr>";
				$("#tablebody").append(html);
			}
		
		},function(){
			//console.log("查询出错");
		});
*/
}
